home *** CD-ROM | disk | FTP | other *** search
- ;A diffuse bump map effect with one directional and one ambient light
- ; Packing definition
- ;
- ; v0 = position
- ; v1 = normal
- ; v2 = texture coords
- ; v3 = tangent
- ; v4 = binormal
-
- ;Constant map from the NSF.
- ;
- ;WorldViewProjTranspose 0 0
- ;InvWorldTranspose 4 0
- ;DirLight1Direction 8 1
- ;AmbLightColor 9 1
- ;MaterialAmbient 10 0
- ;MaterialDiffuse 11 0
-
- vs.1.1
-
- ; Output transformed vertex into device coordinates.
- m4x4 oPos, v0, c0
-
- ; Output texture coordinates.
- mov oT0.xy, v2
- mov oT1.xy, v2
-
- ; Find light vector in object space
- mov r5, c8 ;Get the light direction in world space.
- m3x3 r4, r5, c4 ;Transform to object space with inverse world mat
-
- ; Normalize light vector.
- dp3 r3.x, r4, r4
- rsq r2.x, r3.x
- mul r0, r4.xyz, r2.xxx
-
- ;Transform the light vector into tangent space so we can use in the pixel
- ;shader.
- dp3 r2.x, r0, v3 ;Tangent
- dp3 r2.y, r0, v4 ;Binormal
- dp3 r2.z, r0, v1 ;Normal
- mad oT2.xyz, r2, c12, c12 ;Scale and bias since texcoord in the pixel shader
- ;expects a range of 0 to 1.
-
- ;Ambient Lighting - rest will be done in ps
- mov r1, c10 ;Move in the ambient material so we can multiply
- mul oD0, r1, c9 ;Modulate the ambient light by material
- mov oD1, c11 ;Place the diffuse material in oD1 for use in
- ;the pixel shader.
-
-